/**
 * 
 */
package com.pocketpets.ui.map;

import java.util.ArrayList;

import org.json.JSONObject;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;

import com.google.android.maps.MapView;
import com.google.gson.Gson;
import com.pocketpets.globaldata.LocationData;
import com.pocketpets.main.CatchActivity;
import com.pocketpets.model.map.CaughtItemListClass;

/**
 * @author SumMac
 * 
 */
public class AttractionLayerTw extends FLayerBack {

	// ================================================================
	// Fields
	// ================================================================

	private static Context mContext;
	private ArrayList<JSONObject> aJObject;
	private ArrayList<Gson> aGsonObject;
	private LocationData[] aAttrStruct;

	// ================================================================
	// Constructors
	// ================================================================

	public AttractionLayerTw(Drawable defaultMarker, MapView mapView) {
		super(defaultMarker, mapView);
		mContext = mapView.getContext();

		// TODO Auto-generated constructor stub
	}

	// ================================================================
	// Inheried methods
	// ================================================================

	@Override
	protected boolean onBalloonTap(int index, Spot item) {
		// mContext.startActivity(new Intent(mContext,AttractionInfo.class));

		
		CaughtItemListClass caughtList=CaughtItemListClass.getInstance();
		LocationData object=new LocationData(item.getTitle(),item.getPoint().getLatitudeE6()/1e+6,item.getPoint().getLongitudeE6()/1e+6,1,item.getSnippet(),1);
		caughtList.getItemList().add(object);
		goAttractionInfo(object);
		/*
		 * @Override protected boolean onBalloonTap(int index, Spot item) {
		 * //mContext.startActivity(new Intent(mContext,AttractionInfo.class));
		 * 
		 * aJObject=Attraction.getAttraction(15, item.getSnippet()); //get
		 * attraction from id //aGonObject=Attraction.getAttraction(15,
		 * item.getSnippet()); //aGonObject if (aJObject.size()<=1) {
		 * goAttractionInfo(aJObject.toString()); } else { final CharSequence
		 * []items= new CharSequence[aJObject.size()]; for (int i=0;i<
		 * aJObject.size();i++) { aJObject.get(i); try { Log.i("List",
		 * aJObject.get(i).toString());
		 * items[i]=aJObject.get(i).getString("title"); } catch (JSONException
		 * e) { // TODO Auto-generated catch block e.printStackTrace(); } }
		 * AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
		 * builder.setTitle("List Of Attraction"); builder.setItems(items, new
		 * DialogInterface.OnClickListener() { public void
		 * onClick(DialogInterface dialog, int item) {
		 * goAttractionInfo(aJObject.get(item).toString());
		 * 
		 * } }); AlertDialog alert = builder.create(); alert.show(); }
		 */
		// OverlayItem item = spot.get(index);
		// AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
		// dialog.setTitle(item.getTitle());
		// dialog.setMessage(item.getSnippet());
		// dialog.show();
		return true;
	}

	// ================================================================
	// Methods
	// ================================================================

	public void goAttractionInfo(LocationData item) {
		
		
		Intent infoIntent = new Intent(mContext, CatchActivity.class);
		Bundle bundle = new Bundle();
		bundle.putString("pic", item.getPic());
		//bundle.putSerializable("attractionStruct", new
		// AttractionStructure());
		infoIntent.putExtras(bundle);
		mContext.startActivity(infoIntent);
	}

}
